package com.luozhili.AWT;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Start2 {
    public static void main(String[] args) {
        Frame frame = new Frame("关闭窗口测试");
        frame.setBounds(1200, 250, 300, 400);

        //添加   窗口-事件监听
        //自己实现的适配器
//        frame.addWindowListener(new WinAdapter(){
//            @Override
//            public void windowClosing(WindowEvent e) {
//                System.exit(0);
//            }
//        });
        //用jdk自带适配器
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });


        frame.setVisible(true);
    }
}
